package flextv.main.logic {

import flash.events.Event;

import flextv.data.MockPersistenceService;
import flextv.data.PersistenceServiceImpl;
import flextv.main.logic.download.DownloadServiceImpl;
import flextv.main.logic.download.MockDownloadService;
import flextv.search.logic.MockSearchService;
import flextv.search.logic.SearchServiceImpl;
import flextv.search.logic.SearchServices;

import org.springextensions.actionscript.context.support.FlexXMLApplicationContext;
	

public class SpringApplicationContext {
	
	/** spring-beans */
	private static const _requiredClasses: Array = [
		SearchServices,
			SearchServiceImpl, MockSearchService,
		MainServices,
			DownloadServiceImpl, MockDownloadService,
			PersistenceServiceImpl, MockPersistenceService
	];
	
	private var appContext: FlexXMLApplicationContext;
	
	public function SpringApplicationContext(fnAppContextComplete: Function, contextFile: String = "application-context.xml") {
		if(fnAppContextComplete == null) throw new ArgumentError("fnAppContextComplete == null");
		
		appContext = new FlexXMLApplicationContext("config/" + contextFile);
		appContext.addEventListener(Event.COMPLETE, fnAppContextComplete);
	}
	
	public function load(): void {
		appContext.load();
	}

}
}